<template>
  <view class="message-item-root" @click="showOpinionAppeal">
    <view class="title-container">
      <view class="title">{{ messageData.liaisonId_dictText || messageData.opinionType_dictText }}</view>
      <view :class="messageData.status == '0' ? ['error','state'] : ['success','state']">{{
          messageData.status == '0' ? '未回复' : '已回复'
        }}
      </view>
    </view>
    <view class="content-container text-content">
      {{ messageData.messageContent || messageData.opinionContent }}
    </view>
    <view class="time-container icon-container">
      <i-icon class="icon-root" size="30rpx" name="time-line"></i-icon>
      在{{ messageData.lastTime }}向
      <text class="imp-text" @click.stop="showLiaisonStationOrRepresentativeInfo">{{ messageData.lastMessage }}</text>
      提交了建议
    </view>
  </view>
</template>

<script>
import {baseMixins} from "@/mixins/baseMixins";
import {opinionAppeal} from "@/until/publicConfig";

export default {
  name: "messageItem",
  mixins: [baseMixins],
  props: {
    messageData: {
      type: Object,
      default: () => {
      }
    },
    submitUrl: {
      type: String
    },
    queryUrl: {
      type: String
    },
  },
  methods: {
    showLiaisonStationOrRepresentativeInfo() {
      let {messageData: {infoUrl, infoQuery}} = this;
      this.goSubPage(`${infoUrl}?${infoQuery}`)
    },
    showOpinionAppeal() {
      let {messageData: {id: liaisonMessageId}} = this;
      this.goSubPage(`${opinionAppeal}?liaisonMessageId=${liaisonMessageId}&queryUrl=${this.queryUrl}&submitUrl=${this.submitUrl}`)
    },
  }
}
</script>

<style scoped lang="scss">
.message-item-root {
  width: 100%;
  border-radius: 20rpx;
  padding: 20rpx;
  background: #fff;
  margin-bottom: 30rpx;

  .title-container, .content-container, .time-container {
    width: 100%;
    align-items: flex-start !important;

    .icon-root {
      position: relative;
      top: 4rpx;
    }
  }

  .time-container {
    display: -webkit-box;
    -webkit-line-clamp: 2; /* 显示两行 */
    -webkit-box-orient: vertical; /* 垂直布局 */
    overflow: hidden; /* 隐藏超出的内容 */
  }

  .title-container {
    padding-bottom: 20rpx;
    display: flex;
    flex-direction: row;
    border-bottom: 1rpx solid #E1E1E1;
    align-items: center;
    justify-content: flex-start;

    .title {
      margin-right: 25rpx;
      font-weight: 600;
      font-size: 32rpx;
      color: #222222;
      text-align: left;
      font-style: normal;
      text-transform: none;
      letter-spacing: 2rpx;
    }

    .state {
      display: flex;
      align-items: center;
      min-width: 100rpx;
      height: 50rpx;
      border-radius: 10rpx;
      padding: 0 14rpx;
      font-weight: 400;
      font-size: 24rpx;
      text-align: left;
      font-style: normal;
      text-transform: none;

      &.error {
        background: #FCD1D1;
        color: #B90303;
      }

      &.success {
        background: #DBE5FB;
        color: #3A78FE;
      }
    }
  }

  .content-container {
    margin-top: 20rpx;
    margin-bottom: 20rpx;
    text-indent: 0 !important;
  }

  .time-container {
    font-weight: normal;
    font-size: 30rpx;
    color: #999;
    text-align: left;
    font-style: normal;
    text-transform: none;
    margin-bottom: 20rpx;

    .info-icon {
      margin-right: 10rpx;
    }
  }
}
</style>
